/**
 * Created by Administrator on 2018/11/29.
 */
$CertusJsonAjax.ajax("borrowById",{
    "processInstanceId": $CertusJsonAjax.getProInstanceId(),
    "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
},function(res){

    $$scope.borrow = {}
    $$scope.borrow.personVisible = true;
    //personal select
    $$scope.personalSelect = [
        {name:"个人",code:"personal"},
        {name:"项目",code:"project"}
    ]

    $$scope.wkStepName = $CertusJsonAjax.getWkStepName();

    $$scope.borrow = res.data;

    if($$scope.borrow.borrowingType == "personal"){
        $$scope.borrow.personVisible = true;
    }else{
        $$scope.borrow.personVisible = false;
    }

    $$scope.processs = res.data.processs;
    $$scope.processCCBXTrace = res.data.processs;
    $$scope.borrowStep = {
        "processInstanceId": $CertusJsonAjax.getProInstanceId(),
        "stepInstanceId": $CertusJsonAjax.getStepInstanceId()
    }
})

$$scope.personChange = function(){
    if($$scope.borrow.borrowingType == "personal"){
        $$scope.borrow.borrowingName = "个人";
        $$scope.borrow.personVisible = true;
    }else{
        $$scope.borrow.borrowingName = "项目";
        $$scope.borrow.personVisible = false;
    }
}

$$scope.getsssbbb = function(bb){
    ;
    //starting denied sentback others completed
    if(bb == "starting"){
        return "正在进行中";
    }else if(bb == "denied"){
        return "否决";
    }else if(bb == "sentback"){0
        return "被退";
    }else if(bb == "others"){
        return "关闭";
    }else if(bb == "completed"){
        return "完成";    }else if(bb == "terminated"){        return "终结";    }    else if(bb == "cancelled"){        return "通过";}
    return "待办";
}

//继续提交
$$scope.borrowApproval = function(){
    $CertusJsonAjax.ajax("borrowApproval",$$scope.borrowStep,function(res){
        if(res.data == "success"){
            findBacklogPerson($CertusFormAjax,$CertusJsonAjax.getStepInstanceId());
            history.back();
        }
    })
}

$$scope.borrowingDenied = function(){
    $CertusJsonAjax.ajax("borrowingDenied",$$scope.borrowStep,function(res){
            // findBacklogPerson($CertusFormAjax,$CertusJsonAjax.getStepInstanceId());.
            layer.msg(res.data);
            history.back();
    })
}

$$scope.shutDown = function(){
    $CertusJsonAjax.ajax("shutDownBorrow",$$scope.borrowStep,function(res){
        // findBacklogPerson($CertusFormAjax,$CertusJsonAjax.getStepInstanceId());.
        layer.msg("已经否决");
        history.back();
    })
}

function showProInfo(){
    if($$scope.borrow.projName != "个人"){

        $$scope.proId = $$scope.borrow.projId;
        probox($$scope, $CertusFormAjax);
    }
}